package jsqlite;

import java.io.IOException;
import java.io.OutputStream;

/* compiled from: Blob.java */
/* loaded from: classes2.dex */
class BlobW extends OutputStream {
    private Blob blob;
    private int pos = 0;

    @Override // java.io.OutputStream, java.io.Flushable
    public void flush() throws IOException {
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public BlobW(Blob blob) {
        this.blob = blob;
    }

    @Override // java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable
    public void close() throws IOException {
        this.blob.close();
        this.blob = null;
        this.pos = 0;
    }

    @Override // java.io.OutputStream
    public void write(int i) throws IOException {
        byte[] bArr = {(byte) i};
        int i2 = this.pos;
        this.pos = i2 + this.blob.write(bArr, 0, i2, 1);
    }

    @Override // java.io.OutputStream
    public void write(byte[] bArr) throws IOException {
        if (bArr == null || bArr.length <= 0) {
            return;
        }
        int i = this.pos;
        this.pos = i + this.blob.write(bArr, 0, i, bArr.length);
    }

    @Override // java.io.OutputStream
    public void write(byte[] bArr, int i, int i2) throws IOException {
        if (bArr != null) {
            if (i + i2 > bArr.length) {
                i2 = bArr.length - i;
            }
            if (i2 <= 0) {
                return;
            }
            int i3 = this.pos;
            this.pos = i3 + this.blob.write(bArr, i, i3, i2);
        }
    }
}
